package com.gl.common.vo;

import java.io.Serializable;

/**
 * @Author: wangrl
 * @Description: TODO
 * @Date: 21:34 2018/7/26
 * @Version: 1.0
 */
public class ResultBean<T> implements Serializable {
	private static final long serialVersionUID = 1L;

	private String msg; // 提示信息
	private String code; // 返回状态码
	private T resultData; // 结果数据

	public ResultBean() {
		super();
	}

	public ResultBean(T resultData) {
		super();
		this.resultData = resultData;
	}

	public ResultBean(Throwable e) {
		super();
		this.msg = e.getMessage();
	}

	public T getResultData() {
		return resultData;
	}

	public void setResultData(T resultData) {
		this.resultData = resultData;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}






	/**
	 * 参数错误10004
	 *
	 * @param msg
	 * @return
	 * @author chensenrong
	 */
	public static <T> ResultBean<T> failedResultOfParamWithMsg(String msg) {
		ResultBean<T> resultBean = new ResultBean<>();
		//resultBean.setCode(StatusCode.ERROR_CODE_10004.getErrorCode());
		resultBean.setMsg(msg);
		return resultBean;
	}

	/**
	 * 失败
	 *
	 * @param code
	 * @param msg
	 * @return
	 * @author chensenrong
	 */
	public static <T> ResultBean<T> failedResultWithCodeAndMsg(String code, String msg) {
		ResultBean<T> resultBean = new ResultBean<>();
		resultBean.setCode(code);
		resultBean.setMsg(msg);
		return resultBean;
	}






}
